<script type="text/javascript">
    var tablaId = "#rolsTabla";
    var nuevoModalId = "#nuevorol";
    var editarModalId = "#editarrol";
    var eliminarModalId = "#eliminarrol";
    var nameInputId = "rol_nombre";
    var validateNameUrl = "<%= request.protocol + request.host_with_port %>/rols/existe/nombre";
    var nuevoButtonId = "#new_deposito";
    var editarButtonId = "#editardeposito";
    var eliminarButtonId = "#eliminardeposito";
</script>

<%= javascript_include_tag :'david-crud' %>

<script type="text/javascript">
    $(document).ready(function() {
        $("#rolsTabla").tablesorter({ headers: { 0:{sorter: false}}})
                .tablesorterPager({container: $("#pager"),positionFixed: false , size: 30});

        $.validator.addMethod("nombre_unico", validar_nombre_unico, "");

        $("#new_rol").validate({
            rules: {
                "rol[nombre]": {
                    required: true,
                    nombre_unico: true
                }
            },
            messages: {
                "rol[nombre]": {
                    required: "<%= t('mandatory') %>",
                    nombre_unico: "<%= t('name_exist') %>"
                }
            }
        });
    });
</script>

<% @titulo = t('.title_pag') %>

<%= render "shared/encabezado_crud" %>
<!-- Menu y contenido-->
<div id="sgw_4_body" class="body sg_scroll_container sgw_entity_query_entity_query_page">

  <div class="contents" id="ext-gen77" >

    <%
       @filtroTexto = t('filtro')
       @verListaTexto = t('viewList')
       @verIconosTexto = t('viewSharp')

       @nuevoBotonId = "nuevo_rol"
       @nuevoBotonTexto = t('add')
       @nuevoPath = rols_path
       @nuevoModal = "nuevorol"

       @editarBotonId = "editar_rol"
       @editarBotonTexto = t('edit')
       @editarPath = "#"
       @editarModal = "editartipodeposito"

       @eliminarBotonId = "eliminar_rol"
       @eliminarBotonTexto = t('delete')
       @eliminarPath = "#"
       @eliminarModal = "eliminartipodeposito"
       @eliminarConfirm = "EstÃ¡ seguro de querer eliminar la deposito?"
    %>

    <%= render "shared/menu_crud" %>


    <!-- Formas de visualizaciÃ³n en tabla o thumbnail,...-->
    <div id="layout_principal" class="sgw_new_grid sgw_entity_query_mode sg_scroll_container seltarget" style="left: 250px; top: 30px; ">
      <%
         if(@rols.count == 0)
      %>
          <div class="addnew">
            <%= t('no_created')%>.<br /><br />
            <a data-toggle="modal" role="button" class="btn" href="#nuevorol">
              <%= image_tag "/images/add.png" %><br /><br />
              <%= t('add_new')%>.
            </a>
          </div>
      <%
         else
      %>
      <table id="rolsTabla" class="table table-bordered table-striped tablesorter" >
        <thead>
        <tr>
          <th></th>
          <th><%= t('nombre')%> </th>
          <th><%= t('descr')%> </th>
        </tr>
        </thead>
        <tbody>
        <% @rols.each do |rol| %>
            <tr id="<%= rol.id %>">
              <td width="20px"><input type="checkbox"/></td>
              <td>
                <%= link_to rol.nombre, "#" %></td>
              <td> <%= rol.descripcion %></td>
            </tr>
        <% end %>
        </tbody>
      </table>
     <% end %>
    </div>

    <%= render "shared/filtro_crud" %>


    <%
       @pagTexto = @rols.count.to_s() + " " + t('listade')
       @porPagTexto = t('pag')
    %>

    <%= render "shared/footer_crud" %>
  </div>

</div>


<% content_for :modal do %>
    <div id="nuevorol" class="modal hide fade " role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3><%= t('add')%> <%= t('rol')%></h3>
      </div>

      <div class="modal-body">
        <div class="row-fluid">
          <%= form_for(@rol, :html=> {:multipart=>true}) do |f| %>

              <fieldset>

                <div id="rols">
                  <div class="field">
                    <%= f.label :nombre, t('nombre')%>
                    <%= f.text_field :nombre %>
                  </div>
                  <div class="field">
                    <%= f.label :descripcion, t('descr') %>
                    <%= f.text_area :descripcion, :size => "30x10" %>
                  </div>
                </div>
              </fieldset>

              </div>
              </div>
              <div class="modal-footer">
                <div class="actions"  align=right >

                  <input id="crear_rol" class="btn primary"  name="commit" type="submit" value=" <%= t('btnCrear')%>" />
                  <button class="btn" data-dismiss="modal" aria-hidden="true" ><%= t('btnCancelar')%></button>
                </div>
              </div>
          <% end %>

          </div>
<%end%>

